﻿using System.Collections;
using System;

namespace Mota.XMLControls
{
    public abstract class GuiNumeric : GuiControl
    {
        public override void Add(GuiControl guiControl)
        {
            //empty
        }

        public override IEnumerator GetEnumerator()
        {
            return null;
        }

        public virtual bool IsValid
        {
            get
            {
                return true;
            }
        }
        public abstract decimal Max { get; set; }
        public abstract decimal Min { get; set; }
        public override void SetPropertyValue(String properyName, String propertyValue)
        {
            base.SetPropertyValue(properyName, propertyValue);

            switch (properyName)
            {
                case "Min":
                    decimal parsedMinValue;
                    if (Decimal.TryParse(propertyValue, out parsedMinValue))
                    {
                        Min = parsedMinValue;
                    }
                    break;
                case "Max":
                    decimal parsedMaxValue;
                    if (Decimal.TryParse(propertyValue, out parsedMaxValue))
                    {
                       Max = parsedMaxValue;
                    }
                    break;
            }
        }
        public override void Accept(GuiVisitor visitor)
        {
            visitor.Visit(this);
        }

    }
}
